package com.dayuanit.dy11.mall.mallspringboot.dto;

public class ResponseDTO {
    //1000-成功 9999-失败 5000=登录
    private int code = 1000;
    private String message;
    private Object data;

    public static final int error_code = 9999;
    public static final int error_4_login = 5000;

    private ResponseDTO(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private ResponseDTO(Object data) {
        this.code = code;
        this.data = data;
    }

    private ResponseDTO() {
    }

    public static ResponseDTO success() {
        return new ResponseDTO();
    }

    public static ResponseDTO success(Object data) {
        return new ResponseDTO(data);
    }

    public static ResponseDTO faild(String message) {
        return new ResponseDTO(error_code, message);
    }

    public static ResponseDTO faild4Login() {
        return new ResponseDTO(error_4_login, "请先登录");
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return this.data;
    }
}
